package com.fang.service;


import com.fang.mapper.ProviceMapper;
import com.fang.pojo.Provice;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional
@SuppressWarnings("all")
public class ProviceServiceImpl implements ProviceService {

    @Autowired
    private ProviceMapper proviceMapper;

    @Override
    public List<Provice> findByPage(Integer page, Integer rows) {
        Integer start = (page - 1) * rows;
        return proviceMapper.findByPage(start, rows);
    }

    @Override
    public Integer findTotals() {
        return proviceMapper.findTotals();
    }

    @Override
    public void save(Provice provice) {
        provice.setPlaceCounts(0);   // 初始化的省份景点个数为0
        proviceMapper.save(provice);
    }

    @Override
    public void delete(Integer id) {
        proviceMapper.delete(id);
    }

    @Override
    public Provice findOne(Integer id) {
        return proviceMapper.findOne(id);
    }

    @Override
    public void update(Provice provice) {
        proviceMapper.update(provice);
    }
}
